// 省份城市数据
export const provinceCityData = [
  {
    id: '110000',
    name: '北京市',
    cities: [
      { id: '110101', name: '东城区' },
      { id: '110102', name: '西城区' },
      { id: '110105', name: '朝阳区' },
      { id: '110106', name: '丰台区' },
      { id: '110107', name: '石景山区' },
      { id: '110108', name: '海淀区' },
      { id: '110109', name: '门头沟区' },
      { id: '110111', name: '房山区' },
      { id: '110112', name: '通州区' },
      { id: '110113', name: '顺义区' },
      { id: '110114', name: '昌平区' },
      { id: '110115', name: '大兴区' },
      { id: '110116', name: '怀柔区' },
      { id: '110117', name: '平谷区' },
      { id: '110118', name: '密云区' },
      { id: '110119', name: '延庆区' }
    ]
  },
  {
    id: '310000',
    name: '上海市',
    cities: [
      { id: '310101', name: '黄浦区' },
      { id: '310104', name: '徐汇区' },
      { id: '310105', name: '长宁区' },
      { id: '310106', name: '静安区' },
      { id: '310107', name: '普陀区' },
      { id: '310109', name: '虹口区' },
      { id: '310110', name: '杨浦区' },
      { id: '310112', name: '闵行区' },
      { id: '310113', name: '宝山区' },
      { id: '310114', name: '嘉定区' },
      { id: '310115', name: '浦东新区' },
      { id: '310116', name: '金山区' },
      { id: '310117', name: '松江区' },
      { id: '310118', name: '青浦区' },
      { id: '310120', name: '奉贤区' },
      { id: '310151', name: '崇明区' }
    ]
  },
  {
    id: '440000',
    name: '广东省',
    cities: [
      { id: '440100', name: '广州市' },
      { id: '440300', name: '深圳市' },
      { id: '440400', name: '珠海市' },
      { id: '440500', name: '汕头市' },
      { id: '440600', name: '佛山市' },
      { id: '440700', name: '江门市' },
      { id: '440800', name: '湛江市' },
      { id: '440900', name: '茂名市' },
      { id: '441200', name: '肇庆市' },
      { id: '441300', name: '惠州市' },
      { id: '441400', name: '梅州市' },
      { id: '441500', name: '汕尾市' },
      { id: '441600', name: '河源市' },
      { id: '441700', name: '阳江市' },
      { id: '441800', name: '清远市' },
      { id: '441900', name: '东莞市' },
      { id: '442000', name: '中山市' },
      { id: '445100', name: '潮州市' },
      { id: '445200', name: '揭阳市' },
      { id: '445300', name: '云浮市' }
    ]
  },
  {
    id: '330000',
    name: '浙江省',
    cities: [
      { id: '330100', name: '杭州市' },
      { id: '330200', name: '宁波市' },
      { id: '330300', name: '温州市' },
      { id: '330400', name: '嘉兴市' },
      { id: '330500', name: '湖州市' },
      { id: '330600', name: '绍兴市' },
      { id: '330700', name: '金华市' },
      { id: '330800', name: '衢州市' },
      { id: '330900', name: '舟山市' },
      { id: '331000', name: '台州市' },
      { id: '331100', name: '丽水市' }
    ]
  },
  {
    id: '320000',
    name: '江苏省',
    cities: [
      { id: '320100', name: '南京市' },
      { id: '320200', name: '无锡市' },
      { id: '320300', name: '徐州市' },
      { id: '320400', name: '常州市' },
      { id: '320500', name: '苏州市' },
      { id: '320600', name: '南通市' },
      { id: '320700', name: '连云港市' },
      { id: '320800', name: '淮安市' },
      { id: '320900', name: '盐城市' },
      { id: '321000', name: '扬州市' },
      { id: '321100', name: '镇江市' },
      { id: '321200', name: '泰州市' },
      { id: '321300', name: '宿迁市' }
    ]
  },
  {
    id: '510000',
    name: '四川省',
    cities: [
      { id: '510100', name: '成都市' },
      { id: '510300', name: '自贡市' },
      { id: '510400', name: '攀枝花市' },
      { id: '510500', name: '泸州市' },
      { id: '510600', name: '德阳市' },
      { id: '510700', name: '绵阳市' },
      { id: '510800', name: '广元市' },
      { id: '510900', name: '遂宁市' },
      { id: '511000', name: '内江市' },
      { id: '511100', name: '乐山市' },
      { id: '511300', name: '南充市' },
      { id: '511400', name: '眉山市' },
      { id: '511500', name: '宜宾市' },
      { id: '511600', name: '广安市' },
      { id: '511700', name: '达州市' },
      { id: '511800', name: '雅安市' },
      { id: '511900', name: '巴中市' },
      { id: '512000', name: '资阳市' },
      { id: '513200', name: '阿坝藏族羌族自治州' },
      { id: '513300', name: '甘孜藏族自治州' },
      { id: '513400', name: '凉山彝族自治州' }
    ]
  },
  {
    id: '420000',
    name: '湖北省',
    cities: [
      { id: '420100', name: '武汉市' },
      { id: '420200', name: '黄石市' },
      { id: '420300', name: '十堰市' },
      { id: '420500', name: '宜昌市' },
      { id: '420600', name: '襄阳市' },
      { id: '420700', name: '鄂州市' },
      { id: '420800', name: '荆门市' },
      { id: '420900', name: '孝感市' },
      { id: '421000', name: '荆州市' },
      { id: '421100', name: '黄冈市' },
      { id: '421200', name: '咸宁市' },
      { id: '421300', name: '随州市' },
      { id: '422800', name: '恩施土家族苗族自治州' },
      { id: '429004', name: '仙桃市' },
      { id: '429005', name: '潜江市' },
      { id: '429006', name: '天门市' },
      { id: '429021', name: '神农架林区' }
    ]
  },
  {
    id: '430000',
    name: '湖南省',
    cities: [
      { id: '430100', name: '长沙市' },
      { id: '430200', name: '株洲市' },
      { id: '430300', name: '湘潭市' },
      { id: '430400', name: '衡阳市' },
      { id: '430500', name: '邵阳市' },
      { id: '430600', name: '岳阳市' },
      { id: '430700', name: '常德市' },
      { id: '430800', name: '张家界市' },
      { id: '430900', name: '益阳市' },
      { id: '431000', name: '郴州市' },
      { id: '431100', name: '永州市' },
      { id: '431200', name: '怀化市' },
      { id: '431300', name: '娄底市' },
      { id: '433100', name: '湘西土家族苗族自治州' }
    ]
  },
  {
    id: '370000',
    name: '山东省',
    cities: [
      { id: '370100', name: '济南市' },
      { id: '370200', name: '青岛市' },
      { id: '370300', name: '淄博市' },
      { id: '370400', name: '枣庄市' },
      { id: '370500', name: '东营市' },
      { id: '370600', name: '烟台市' },
      { id: '370700', name: '潍坊市' },
      { id: '370800', name: '济宁市' },
      { id: '370900', name: '泰安市' },
      { id: '371000', name: '威海市' },
      { id: '371100', name: '日照市' },
      { id: '371200', name: '莱芜市' },
      { id: '371300', name: '临沂市' },
      { id: '371400', name: '德州市' },
      { id: '371500', name: '聊城市' },
      { id: '371600', name: '滨州市' },
      { id: '371700', name: '菏泽市' }
    ]
  },
  {
    id: '120000',
    name: '天津市',
    cities: [
      { id: '120101', name: '和平区' },
      { id: '120102', name: '河东区' },
      { id: '120103', name: '河西区' },
      { id: '120104', name: '南开区' },
      { id: '120105', name: '河北区' },
      { id: '120106', name: '红桥区' },
      { id: '120110', name: '东丽区' },
      { id: '120111', name: '西青区' },
      { id: '120112', name: '津南区' },
      { id: '120113', name: '北辰区' },
      { id: '120114', name: '武清区' },
      { id: '120115', name: '宝坻区' },
      { id: '120116', name: '滨海新区' },
      { id: '120117', name: '宁河区' },
      { id: '120118', name: '静海区' },
      { id: '120119', name: '蓟州区' }
    ]
  }
];

// 获取所有省份
export const getProvinces = () => {
  return provinceCityData.map(province => ({
    id: province.id,
    name: province.name
  }));
};

// 根据省份ID获取城市列表
export const getCitiesByProvinceId = (provinceId) => {
  const province = provinceCityData.find(p => p.id === provinceId);
  return province ? province.cities : [];
};

// 根据城市名称搜索
export const searchCities = (keyword) => {
  if (!keyword || keyword.trim() === '') {
    return [];
  }
  
  const results = [];
  const lowerKeyword = keyword.toLowerCase();
  
  provinceCityData.forEach(province => {
    const matchedCities = province.cities.filter(city => 
      city.name.toLowerCase().includes(lowerKeyword)
    );
    
    if (matchedCities.length > 0) {
      results.push({
        provinceId: province.id,
        provinceName: province.name,
        cities: matchedCities
      });
    }
  });
  
  return results;
};